var t = getApp(), e = require("./base64.js").Base64;

Page({
    data: {
        focusMobile: !0,
        focusPwd: !1
    },
    toPage: function(t) {
        var e = t.currentTarget.dataset.url;
        wx.navigateTo({
            url: e
        });
    },
    changeVal: function(t) {
        var e = {}, o = t.currentTarget.dataset.name, n = t.detail.value;
        e[o] = n, this.setData(e);
    },
    confirm: function() {
        this.login();
    },
    login: function() {
        var o = this;
        this.data.mobile ? this.data.pwd ? t.request({
            url: t.server + "/userApi/ourLogin",
            method: "POST",
            data: {
                mobile: this.data.mobile,
                password: e.encode(this.data.pwd),
                is_web: 1,
                type: 2
            },
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                if (0 === t.data.code) {
                    wx.setStorageSync("usr", t.data.result.userInfo);
                    var e = getCurrentPages(), n = (e[e.length - 2], !0), a = !1, i = void 0;
                    try {
                        for (var r, s = e[Symbol.iterator](); !(n = (r = s.next()).done); n = !0) {
                            var c = r.value;
                            c.reload && c.reload();
                        }
                    } catch (t) {
                        a = !0, i = t;
                    } finally {
                        try {
                            !n && s.return && s.return();
                        } finally {
                            if (a) throw i;
                        }
                    }
                    wx.navigateBack();
                } else wx.showToast({
                    icon: "none",
                    title: t.data.msg.zh,
                    complete: function() {
                        o.setData({
                            focusPwd: !0
                        });
                    }
                });
            }
        }) : wx.showToast({
            icon: "none",
            title: "请输入密码",
            complete: function() {
                o.setData({
                    focusPwd: !0
                });
            }
        }) : wx.showToast({
            icon: "none",
            title: "请输入手机号码",
            complete: function() {
                o.setData({
                    focusMobile: !0
                });
            }
        });
    },
    onLoad: function(t) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});